//
//  SPMineViewController.m
//  Sport
//
//  Created by Cass on 2017/12/2.
//  Copyright © 2017年 Cass. All rights reserved.
//

#import "SPMineViewController.h"
#import "SPMyInformationViewController.h"
#import "SPStateViewController.h"
#import "SPCollectViewController.h"
#import "SPIdeaViewController.h"
#import "SPSetupViewController.h"
@interface SPMineViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;


@end

@implementation SPMineViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

#pragma mark - UITableViewDelegate -
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"You Selected %@",[tableView cellForRowAtIndexPath:indexPath].textLabel.text);
    if (indexPath.section == 0) {
        SPMyInformationViewController *myinfoVC = [[UIStoryboard storyboardWithName:@"Mine" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:NSStringFromClass([SPMyInformationViewController class])];
        myinfoVC.title = @"我的资料";
        [self.navigationController pushViewController:myinfoVC animated:YES];
    }else if (indexPath.section == 1){
        if (indexPath.row == 0) {
            SPStateViewController *stateVC = [[UIStoryboard storyboardWithName:@"Mine" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:NSStringFromClass([SPStateViewController class])];
            stateVC.title = @"我的动态";
            [self.navigationController pushViewController:stateVC animated:YES];
        }else{
            SPCollectViewController *collectVC = [[UIStoryboard storyboardWithName:@"Mine" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:NSStringFromClass([SPCollectViewController class])];
            collectVC.title = @"我的收藏";
            [self.navigationController pushViewController:collectVC animated:YES];
        }
    }else{
        if (indexPath.row == 0) {
            SPIdeaViewController *ideaVC = [[UIStoryboard storyboardWithName:@"Mine" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:NSStringFromClass([SPIdeaViewController class])];
            ideaVC.title = @"意见反馈";
            [self.navigationController pushViewController:ideaVC animated:YES];
        }else if (indexPath.row == 1){
            SPSetupViewController *setupVC = [[UIStoryboard storyboardWithName:@"Mine" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:NSStringFromClass([SPSetupViewController class])];
            setupVC.title = @"设置";
            [self.navigationController pushViewController:setupVC animated:YES];
        }
    }
}

#pragma mark - UITableViewDataSource -
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if(section == 0) {
        return 1;
    }else if (section == 1){
        return 2;
    }else{
        return 3;
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *ID = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    if (indexPath.section == 0) {
        cell.textLabel.text = @"我";
    }else if (indexPath.section == 1){
        if (indexPath.row == 0) {
            cell.textLabel.text = @"我的动态";
        }else if (indexPath.row == 1){
            cell.textLabel.text = @"收藏";
        }
    }else{
        if (indexPath.row == 0) {
            cell.textLabel.text = @"意见反馈";
        }else if (indexPath.row == 1){
            cell.textLabel.text = @"设置";
        }else{
            cell.textLabel.text = @"退出";
        }
    }
//    tableView.rowHeight = 67.0f;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
//- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section{
//    if (section == 0) {
//        return @" ";
//    }else if (section == 1){
//        return @" ";
//    }else{
//        return @" ";
//    }
//}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        return 87.0f;
    }else{
        return 67.0f;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 5.0f;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}


@end
